import { PageContainer } from '@ant-design/pro-components';
import BookForm from "./components/bookForm"
import {useState} from "react"
import {addBookApi} from "@/services/book"
import {useNavigate} from "umi"
import {message} from "antd" 
export default function AddBook() {
  const navigator = useNavigate()
  const [bookInfo,setBookInfo ] = useState({
  })
  function submit(target){
    console.log("要提交的对象",target)
    addBookApi(target).then(()=>{
      // 跳转首页
      navigator('/book/bookList');
      message.success('新增书籍成功')
    })
  }
  return (
    <PageContainer
    header={{
      breadcrumb: {
        items: [
          {
            title: '书籍',
          },
          {
            title: '添加书籍',
          },
        ],
      },
    }} 
    >
      <BookForm type="add" submit={submit} initData={bookInfo}/>
    </PageContainer>
  );
}
